using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class so_TreatHistoryMap : EntityTypeConfiguration<so_TreatHistory>
    {
        public so_TreatHistoryMap()
        {
            // Primary Key
            this.HasKey(t => new { t.entry_date, t.operate_id, t.qty, t.SumFields, t.Dimfields });

            // Properties
            this.Property(t => t.code)
                .HasMaxLength(10);

            this.Property(t => t.Case__)
                .HasMaxLength(15);

            this.Property(t => t.Patient)
                .HasMaxLength(110);

            this.Property(t => t.Physician)
                .HasMaxLength(35);

            this.Property(t => t.Admisionid)
                .HasMaxLength(10);

            this.Property(t => t.Patient_id)
                .HasMaxLength(6);

            this.Property(t => t.Diagnosis_Code)
                .HasMaxLength(35);

            this.Property(t => t.Diagnosis_Description)
                .HasMaxLength(200);

            this.Property(t => t.operate_id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Treatement_Status)
                .HasMaxLength(13);

            this.Property(t => t.qty)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Price_List)
                .HasMaxLength(50);

            this.Property(t => t.HeaderView)
                .HasMaxLength(40);

            this.Property(t => t.SumFields)
                .IsRequired()
                .HasMaxLength(78);

            this.Property(t => t.Dimfields)
                .IsRequired()
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("so_TreatHistory");
            this.Property(t => t.code).HasColumnName("code");
            this.Property(t => t.Tooth__).HasColumnName("Tooth_#");
            this.Property(t => t.Case__).HasColumnName("Case_#");
            this.Property(t => t.Patient).HasColumnName("Patient");
            this.Property(t => t.entry_date).HasColumnName("entry_date");
            this.Property(t => t.Physician).HasColumnName("Physician");
            this.Property(t => t.Admisionid).HasColumnName("Admisionid");
            this.Property(t => t.Patient_id).HasColumnName("Patient_id");
            this.Property(t => t.Diagnosis_Code).HasColumnName("Diagnosis_Code");
            this.Property(t => t.Diagnosis_Description).HasColumnName("Diagnosis_Description");
            this.Property(t => t.operate_id).HasColumnName("operate_id");
            this.Property(t => t.Treatement_Status).HasColumnName("Treatement_Status");
            this.Property(t => t.qty).HasColumnName("qty");
            this.Property(t => t.Price_List).HasColumnName("Price_List");
            this.Property(t => t.Price).HasColumnName("Price");
            this.Property(t => t.Discount).HasColumnName("Discount");
            this.Property(t => t.Net_Amount).HasColumnName("Net_Amount");
            this.Property(t => t.Patient_Amount).HasColumnName("Patient_Amount");
            this.Property(t => t.Guarantor1_Amount).HasColumnName("Guarantor1_Amount");
            this.Property(t => t.Guarantor2_Amount).HasColumnName("Guarantor2_Amount");
            this.Property(t => t.HeaderView).HasColumnName("HeaderView");
            this.Property(t => t.SumFields).HasColumnName("SumFields");
            this.Property(t => t.Dimfields).HasColumnName("Dimfields");
        }
    }
}
